import Login from '@/pages/login/Login'
import ForgetPassword from '@/pages/login/ForgetPassword'
import Cookie from 'js-cookie'

export default [
  // 登陆
  {
    path: '/login',
    name: 'Login',
    component: Login,
    beforeEnter: (to, from, next) => {
      // 在访问login路由前进行登录态的检测
      let token = Cookie.get('token')
      if (token) {
        // 是否存在token，存在就直接跳到首页，token。
        next('/index')
      } else {
        next()
      }
    },
    meta: {
      title: '登录'
    }
  },
  // 忘记密码
  {
    path: '/forget-password',
    name: 'ForgetPassword',
    component: ForgetPassword,
    meta: {
      title: '找回密码'
    }
  }
]
